package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.bean.FaMenBean;

import java.util.ArrayList;

/**
 * 泡泡窗口数据适配
 */
public class PopWindowChoiceWpAdapter extends BaseAdapter{
    private Context context;
    private String [] typess;
    private String type;
    private ArrayList<Boolean> isBoolean;
    ArrayList<FaMenBean.VBean.STATUSBean> listFa;
    public ArrayList<Boolean> getIsBoolean() {
        return isBoolean;
    }

    public void setIsBoolean(ArrayList<Boolean> isBoolean) {
        this.isBoolean = isBoolean;
    }

    public PopWindowChoiceWpAdapter(Context context, ArrayList<FaMenBean.VBean.STATUSBean> listFa, String type) {
        this.context=context;
        this.listFa = listFa;
        this.type=type;
    }

    public PopWindowChoiceWpAdapter(Context context, ArrayList<FaMenBean.VBean.STATUSBean> listFa, String type,String [] typess) {
        this.context=context;
        this.listFa = listFa;
        this.type=type;
        this.typess=typess;
    }
    @Override
    public int getCount() {
        return listFa.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.pop_window_choicewp_item, parent, false);
            holder = new ViewHolder();
            holder.tv_pop_content=(TextView) convertView.findViewById(R.id.tv_pop_content);
            holder.tv_pop_type=(TextView) convertView.findViewById(R.id.tv_pop_type);
            holder.iv_pop_img=(ImageView)convertView.findViewById(R.id.iv_pop_img);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        if(getIsBoolean().get(position)){
            holder.iv_pop_img.setSelected(true);
        }else{
            holder.iv_pop_img.setSelected(false);
        }
           holder.tv_pop_content.setText(listFa.get(position).getNAME());
        if(typess!=null){
            holder.tv_pop_type.setText(typess[position]);
        }
        return convertView;
    }
    private class ViewHolder{
       TextView tv_pop_content;
       TextView tv_pop_type;
        ImageView iv_pop_img;
    }
}
